package com.shangting.web.service.impl;

import com.shangting.common.config.MinioConfig;
import com.shangting.common.utils.MinioUtil;
import com.shangting.web.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

@Service
public class FileServiceImpl implements FileService {

    @Autowired
    private MinioUtil minioUtil;

    @Autowired
    private MinioConfig minioConfig;

    @Override
    public String upload(MultipartFile file) throws Exception {
        String objectName = minioUtil.upload2(file);
        if (null != objectName) {
            System.out.println(minioConfig.getEndpoint() + "/" + minioConfig.getBucketName() + "/" + objectName);
        }
        System.out.println("文件上传返回url:" + objectName);
        return "";
    }
}
